import geopandas as gpd
import json
import altair as alt
def open_geojson():
    with open('india_states.geojson') as json_data:
        d = json.load(json_data)
    return d
gdf = gpd.GeoDataFrame.from_features(open_geojson())
gdf
geometry ID_0 ISO NAME_0 ID_1 NAME_1 NL_NAME_1 VARNAME_1 TYPE_1 ENGTYPE_1 filename filename_1 filename_2 filename_3 filename_4
0 MULTIPOLYGON (((93.78773 6.85264, 93.78849 6.8... 105 IND India 1 Andaman and Nicobar Andaman & Nicobar Islands|Andaman et Nicobar|I... Union Territor Union Territory
1 MULTIPOLYGON (((80.27458 13.45958, 80.27458 13... 105 IND India 2 Andhra Pradesh State State
2 POLYGON ((96.15778 29.38310, 96.16380 29.37668... 105 IND India 3 Arunachal Pradesh Agence de la Frontire du Nord-Est(French-obsol... State State
3 MULTIPOLYGON (((89.87145 25.53730, 89.87118 25... 105 IND India 4 Assam State State
4 MULTIPOLYGON (((88.10548 26.53904, 88.10505 26... 105 IND India 5 Bihar State State
5 POLYGON ((76.81981 30.68583, 76.81051 30.68495... 105 IND India 6 Chandigarh Union Territor Union Territory
6 POLYGON ((83.32760 24.09965, 83.34575 24.09707... 105 IND India 7 Chhattisgarh State State
7 POLYGON ((72.99046 20.29209, 73.00357 20.29314... 105 IND India 8 Dadra and Nagar Haveli DAdra et Nagar Haveli|Dadra e Nagar Haveli Union Territor Union Territory
8 MULTIPOLYGON (((72.86014 20.47096, 72.86340 20... 105 IND India 9 Daman and Diu Union Territor Union Territory
9 POLYGON ((77.21732 28.83528, 77.21365 28.81350... 105 IND India 10 Delhi Union Territor Union Territory
10 MULTIPOLYGON (((73.78181 15.35569, 73.78181 15... 105 IND India 11 Goa Ga State State
11 MULTIPOLYGON (((70.86097 20.75292, 70.86097 20... 105 IND India 12 Gujarat Goudjerate|Gujerat|Gujerate State State
12 POLYGON ((76.83715 30.87887, 76.85243 30.87069... 105 IND India 13 Haryana State State
13 POLYGON ((76.80276 33.23666, 76.80630 33.23623... 105 IND India 14 Himachal Pradesh Union Territor Union Territory
14 POLYGON ((77.89957 35.42789, 77.90297 35.42759... 105 IND India 15 Jammu and Kashmir State State
15 POLYGON ((87.59989 25.31466, 87.60688 25.31138... 105 IND India 16 Jharkhand Vananchal State State
16 MULTIPOLYGON (((74.67097 13.19986, 74.67097 13... 105 IND India 17 Karnataka Maisur|Mysore State State
17 MULTIPOLYGON (((76.46736 9.54097, 76.46736 9.5... 105 IND India 18 Kerala State State
18 MULTIPOLYGON (((73.01014 8.28042, 73.01014 8.2... 105 IND India 19 Lakshadweep les Laquedives|Laccadive|Minicoy and Amindivi ... Union Territor Union Territory
19 POLYGON ((78.36465 26.86884, 78.36688 26.86259... 105 IND India 20 Madhya Pradesh State State
20 MULTIPOLYGON (((73.45597 15.88986, 73.45597 15... 105 IND India 21 Maharashtra State State
21 POLYGON ((94.57723 25.64833, 94.57609 25.64470... 105 IND India 22 Manipur State State
22 POLYGON ((91.85384 26.10479, 91.86470 26.10035... 105 IND India 23 Meghalaya State State
23 POLYGON ((92.80080 24.41905, 92.80370 24.41879... 105 IND India 24 Mizoram State State
24 POLYGON ((95.21445 26.93695, 95.21706 26.93420... 105 IND India 25 Nagaland State State
25 MULTIPOLYGON (((84.76986 19.10597, 84.76986 19... 105 IND India 26 Orissa State State
26 MULTIPOLYGON (((79.84486 10.82653, 79.84486 10... 105 IND India 27 Puducherry Pondicherry|Puduchcheri|Pondichry Union Territor Union Territory
27 POLYGON ((75.86877 32.48868, 75.88712 32.47203... 105 IND India 28 Punjab State State
28 POLYGON ((73.88944 29.97761, 73.89118 29.97007... 105 IND India 29 Rajasthan Greater Rajasthan|Rajputana State State
29 POLYGON ((88.64526 28.09912, 88.65411 28.08984... 105 IND India 30 Sikkim State State
30 MULTIPOLYGON (((77.55596 8.07903, 77.55596 8.0... 105 IND India 31 Tamil Nadu Madras|Tamilnad State State
31 POLYGON ((92.18520 24.52287, 92.18896 24.52019... 105 IND India 32 Tripura State State
32 POLYGON ((77.58468 30.40878, 77.58639 30.40801... 105 IND India 33 Uttar Pradesh United Provinces State State
33 POLYGON ((79.19478 31.35362, 79.19817 31.35196... 105 IND India 34 Uttaranchal Uttarakhand State State
34 MULTIPOLYGON (((88.01861 21.57278, 88.01889 21... 105 IND India 35 West Bengal Bangla|Bengala Occidentale|Bengala Ocidental|B... State State
gdf['count'] = 2
gdf['count'][11]=4
gdf['count'][20]=6
C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:2: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  
C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:3: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  This is separate from the ipykernel package so we can avoid doing imports until
choro_json = json.loads(gdf.to_json())
choro_data = alt.Data(values=choro_json['features'])
def gen_map(geodata,color_column, title, tooltip,color_scheme='bluegreen'):
    '''
    Generates India map 
    '''
    selection = alt.selection_multi(fields=[color_column])
    color = alt.condition(selection,
                  alt.Color(color_column, type='nominal',
                  scale=alt.Scale(scheme=color_scheme)),
                  alt.value('lightgray'))
    
    # Add Base Layer
    base = alt.Chart(geodata).mark_geoshape(
        stroke='black',
        strokeWidth=1
    ).encode(
    ).properties(
        width=800,
        height=800
    )
    # Add Choropleth Layer
    choro = alt.Chart(geodata).mark_geoshape(
        fill='lightgray',
        stroke='black'
    ).encode(
        color=color,
         tooltip=tooltip
    ).add_selection(
        selection
    )
    return base + choro 
alt.themes.enable('opaque')
ThemeRegistry.enable('opaque')
gen_map(geodata=choro_data,
        color_column='properties.count',
        tooltip=['properties.NAME_1:O','properties.count:Q'],
        title='India',
        color_scheme='yelloworangered',)